const fs = require("fs");
module.exports = {
    CloneData: (rowData) => {
        let cache = [];
        return JSON.stringify(rowData, function (key, value) {
            if (typeof value === 'object' && value !== null) {
                if (cache.indexOf(value) !== -1) {
                    return;
                }
                cache.push(value);
            }
            return value;
        });
    },

    AsyncWriteFile: (path, data) => {
        return new Promise((resolve, reject) => {
            fs.writeFile(path, data, (err) => {
                if (!!!err) {
                    resolve()
                } else {
                    reject(err)
                }
            })
        })
    }

}
